<!--$Id: db_cursor.so,v 10.55 2007/10/24 16:06:06 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: Db::cursor</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b>Db::cursor</b>
</td>
<td align=right>
<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a>
<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>
#include &lt;db_cxx.h&gt;
<p>
int
Db::cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags);
</pre></b>
<hr size=1 noshade>
<b>Description: Db::cursor</b>
<p>The Db::cursor method returns a created database cursor.</p>
<p>Cursors may span threads, but only serially, that is, the application
must serialize access to the cursor handle.</p>
<p>The Db::cursor method
either returns a non-zero error value
or throws an exception that encapsulates a non-zero error value on
failure, and returns 0 on success.
</p>
<b>Parameters</b> <br>
 <b>cursorp</b><ul compact><li>The <b>cursorp</b> parameter references memory into which
a pointer to the allocated cursor is copied.</ul> 
 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one
or more of the following values:
<br>
<b><a name="DB_READ_COMMITTED">DB_READ_COMMITTED</a></b><ul compact><li>Configure a transactional cursor to have degree 2 isolation.  This ensures
the stability of the current data item read by this cursor but permits data
read by this cursor to be modified or deleted prior to the commit of the
transaction for this cursor.</ul>
<b><a name="DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a></b><ul compact><li>Configure a transactional cursor to have degree 1 isolation.  Read
operations performed by the cursor may return modified but not yet
committed data.  Silently ignored if the <a href="../api_cxx/db_open.html#DB_READ_UNCOMMITTED">DB_READ_UNCOMMITTED</a>
flag was not specified when the underlying database was opened.</ul>
<b><a name="DB_WRITECURSOR">DB_WRITECURSOR</a></b><ul compact><li>Specify that the cursor will be used to update the database.  The
underlying database environment must have been opened using the
<a href="../api_cxx/env_open.html#DB_INIT_CDB">DB_INIT_CDB</a> flag.</ul>
<b><a name="DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a></b><ul compact><li>Configure a transactional cursor to operate with read-only
<a href="../ref/transapp/read.html">snapshot isolation</a>.  For databases
with the <a href="../api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> flag set, data values will be read as
they are when the cursor is opened, without taking read locks.  This
flag implicitly begins a transaction that is committed when the cursor
is closed.  Silently ignored if <a href="../api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> not set on the
underlying database or if a transaction is supplied in the <b>txnid</b>
parameter.</ul>
<br></ul>
 <b>txnid</b><ul compact><li>Cursor operations are not automatically transaction-protected, even if
the <a href="../api_cxx/env_set_flags.html#DB_AUTO_COMMIT">DB_AUTO_COMMIT</a> flag is specified to the
<a href="../api_cxx/env_set_flags.html">DbEnv::set_flags</a> or <a href="../api_cxx/db_open.html">Db::open</a> methods.  If cursor operations are
to be transaction-protected, the <b>txnid</b> parameter must be a
transaction handle returned from <a href="../api_cxx/txn_begin.html">DbEnv::txn_begin</a>; otherwise, NULL.  To
transaction-protect cursor operations, cursors must be opened and closed
within the context of a transaction, and the <b>txnid</b> parameter
specifies the transaction context in which the cursor may be used.</ul>
<br>
<br><b>Errors</b>
<p>The Db::cursor method
may fail and throw
<a href="../api_cxx/except_class.html">DbException</a>,
encapsulating one of the following non-zero errors, or return one of
the following non-zero errors:</p>
<br>
<b>DB_REP_HANDLE_DEAD</b><ul compact><li>The database handle has been invalidated because a replication election
unrolled a committed transaction.</ul>
<br>
<br>
<b>DB_REP_LOCKOUT</b><ul compact><li>The operation was blocked by client/master synchronization.</ul>
<br>
<br>
<b>EINVAL</b><ul compact><li>An
invalid flag value or parameter was specified.</ul>
<br>
<hr size=1 noshade>
<br><b>Class</b>
<a href="../api_cxx/dbc_class.html">Dbc</a>
<br><b>See Also</b>
<a href="../api_cxx/dbc_list.html">Database Cursors and Related Methods</a>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>
